﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <input type="hidden" id="id" name="id" />
        <div class="form-group">
            <label class="col-sm-3 control-label ">任务组<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="jobGroupName" name="JobGroupName" type="text" class="form-control"  autocomplete="off" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">任务名称<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="jobName" name="JobName" type="text" class="form-control" autocomplete="off"  />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">状态</label>
            <div class="col-sm-8" id="jobStatus" name="JobStatus" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">Cron表达式<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="cronExpression" name="CronExpression" type="text" class="form-control" autocomplete="off" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">开始时间<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="startTime" name="StartTime" type="text" class="form-control" autocomplete="off"  />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">结束时间</label>
            <div class="col-sm-8">
                <input id="endTime" name="EndTime" type="text" class="form-control" autocomplete="off" />
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        $("#jobStatus").ysRadioBox({ data: ys.getJson(@Html.Raw(typeof(StatusEnum).EnumToDictionaryString())) });
        //初始时间
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#startTime',
                theme: 'molv',
                trigger: 'click',
            });
            var endTime = laydate.render({
                elem: '#endTime',
                theme: 'molv',
                trigger: 'click',
            });
        });
        getForm();

        $("#form").validate({
            rules: {
                jobGroupName: { required: true },
                jobName: { required: true },
                cronExpression: { required: true },
                startTime: { required: true }
            }
        });
    });
   
    function getForm() {
        //修改赋值使用
        var editData = storage.get("editData");
        if (editData != null && editData.length > 0) {
            var data = JSON.parse(editData);
            //表单赋值
            $("#form").setWebControls(data);
            $('#menuTree').ysTree("setCheckedNodes", data.menuIds);
        } else {
            //界面初始化
            var defaultData = {};
            defaultData.jobStatus = 1;
            $("#form").setWebControls(defaultData);
        }
    }
    //提交数据
    function submitForm() {
        if ($.validate.form()) {
            var data = $('#form').getWebControls();
            if (data["endTime"]=="") {
                data["endTime"] = "9999-12-31 00:00:00";
            }
            $.operate.save("/SystemManage/AutoJob/SaveFormJson", data);
        }
    }
</script>

